#include <iostream>
#include <string>
using namespace std;

int n;
string s;

int main()
{
    cin >> s;
    cin >> n;
    while (n--)
    {
        string t;
        for (int i = 0; i < s.size();)
        {
            int j = i;
            while (j < s.size() && s[j] == s[i])
                j++;
            int cjb = j - i;
            t += to_string(cjb) + s[i];
            i = j;
        }
        s = t;
    }
    cout << s << endl;
    return 0;
}